/*
 * This file is part of aion-engine <aion-engine.net>
 *
 * aion-engine is private software: you can redistribute it and or modify
 * it under the terms of the GNU Lesser Public License as published by
 * the Private Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * aion-engine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser Public License for more details.
 *
 * You should have received a copy of the GNU Lesser Public License
 * along with aion-engine.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.aionengine.gameserver.network.aion.clientpackets;

import com.aionengine.gameserver.configs.administration.AdminConfig;
import com.aionengine.gameserver.configs.main.GSConfig;
import com.aionengine.gameserver.dataholders.DataManager;
import com.aionengine.gameserver.model.gameobjects.PersistentState;
import com.aionengine.gameserver.model.gameobjects.VisibleObject;
import com.aionengine.gameserver.model.gameobjects.player.Player;
import com.aionengine.gameserver.model.gameobjects.player.QuestStateList;
import com.aionengine.gameserver.model.gameobjects.state.CreatureVisualState;
import com.aionengine.gameserver.model.gm.GmPanelCommands;
import com.aionengine.gameserver.network.aion.AionClientPacket;
import com.aionengine.gameserver.network.aion.AionConnection.State;
import com.aionengine.gameserver.network.aion.serverpackets.SM_PLAYER_STATE;
import com.aionengine.gameserver.network.aion.serverpackets.SM_QUEST_COMPLETED_LIST;
import com.aionengine.gameserver.questEngine.model.QuestState;
import com.aionengine.gameserver.services.item.ItemService;
import com.aionengine.gameserver.services.player.PlayerReviveService;
import com.aionengine.gameserver.services.teleport.TeleportService2;
import com.aionengine.gameserver.skillengine.effect.AbnormalState;
import com.aionengine.gameserver.utils.PacketSendUtility;
import com.aionengine.gameserver.utils.Util;
import com.aionengine.gameserver.world.World;
import com.aionengine.gameserver.model.EmotionType;
import com.aionengine.gameserver.model.stats.calc.Stat2;
import com.aionengine.gameserver.model.stats.calc.StatOwner;
import com.aionengine.gameserver.model.stats.calc.functions.IStatFunction;
import com.aionengine.gameserver.model.stats.calc.functions.StatFunction;
import com.aionengine.gameserver.model.stats.container.StatEnum;
import com.aionengine.gameserver.network.aion.serverpackets.SM_EMOTION;
import java.util.ArrayList;
import java.util.List;


/**
 * @author Magenik
 */
public class CM_GM_COMMAND_SEND extends AionClientPacket implements StatOwner {

    private GmPanelCommands command;
    private String playerName;
    private String parts[];

    public CM_GM_COMMAND_SEND(int opcode, State state, State... restStates) {
        super(opcode, state, restStates);
    }

    @Override
    protected void readImpl() {
        playerName = readS();
        parts = playerName.split(" ");
        command = GmPanelCommands.getValue(parts[0]);
        //playerName = parts[1];
    }

    @Override
    protected void runImpl() {
        Player admin = getConnection().getActivePlayer();
        Player player = World.getInstance().findPlayer(Util.convertName(playerName));
        Player target = getTarget(admin);
        if (admin == null) {
            return;
        }

        // not needed but to be sure
        if (admin.getAccessLevel() < AdminConfig.GM_PANEL) {
            return;
        }

        switch (command) {
            /**
             * @STANDARD FUNCTION TAB
             */
            case REMOVE_SKILL_DELAY_ALL:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case ITEMCOOLTIME:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case CLEARUSERCOOLT:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case SET_MAKEUP_BONUS:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case SET_VITALPOINT:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case SET_DISABLE_ITEMUSE_GAUGE:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case PARTYRECALL:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case ATTRBONUS:
                if (target != null) {
                    if (parts.length == 3) {
                        String action = parts[1];
                        Integer value = Integer.parseInt(parts[2]);
                        if (action.equalsIgnoreCase("speed")) {
                            if (value < 1000) {
                                List functions = new ArrayList();
                                functions.add(new StatChangeFunction(StatEnum.SPEED, value));
                                admin.getGameStats().addEffect(this, functions);
                                PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                            }
                        }
                     else if (action.equalsIgnoreCase("maxhp") || action.equalsIgnoreCase("hp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAXHP, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("hpregen")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.REGEN_HP, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("maxmp") || action.equalsIgnoreCase("mp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAXMP, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("mpregen")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.REGEN_MP, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("flyspeed")) {
                        if (value < 1000) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.FLY_SPEED, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("maxdp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAXDP, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("ARALL")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.ABNORMAL_RESISTANCE_ALL, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("allpara")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.ALLRESIST, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("strvit")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.STRVIT, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("knowil")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.KNOWIL, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("agidex")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.AGIDEX, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("str")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.POWER, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("vit")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.HEALTH, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("agi")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.ACCURACY, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("dex")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.AGILITY, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("kno")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.KNOWLEDGE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("wil")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.WILL, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("ElementalDefendWater")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.WATER_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("ElementalDefendAir")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.WIND_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("ElementalDefendEarth")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.EARTH_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("ElementalDefendFire")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.FIRE_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("FPRegen")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.REGEN_FP, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("physicaldefend")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.PHYSICAL_DEFENSE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("magicalAttack")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAGICAL_ATTACK, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("magicalResist")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAGICAL_RESIST, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    } else if (action.equalsIgnoreCase("attackDelay")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.ATTACK_SPEED, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("dodge")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.EVASION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("parry")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.PARRY, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("block")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.BLOCK, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("critical")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.PHYSICAL_CRITICAL, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("hitCount")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.HIT_COUNT, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("attackRange")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.ATTACK_RANGE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("magicalCritical")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAGICAL_CRITICAL, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("concentration")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.CONCENTRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arPoison")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.POISON_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arBleed")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.BLEED_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arBleed")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.BLEED_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arParalyze")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.PARALYZE_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arSleep")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SLEEP_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arRoot")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.ROOT_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arBlind")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.BLIND_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arCharm")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.CHARM_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arDisease")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.DISEASE_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arSilence")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SILENCE_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arFear")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.FEAR_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arConfuse")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.CONFUSE_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arStun")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.STUN_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arPerification")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.PERIFICATION_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arStumble")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.STUMBLE_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arStagger")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.STAGGER_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arOpenAreial")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.OPENAREIAL_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arSnare")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SNARE_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arSlow")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SLOW_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("arSpin")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SPIN_RESISTANCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Poison Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.POISON_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Bleed Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.BLEED_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Paralyze Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.PARALYZE_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Sleep Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SLEEP_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Root Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.ROOT_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Blind Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.BLIND_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Charm Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.CHARM_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Disease Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.DISEASE_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Silence Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SILENCE_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Fear Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.FEAR_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Curse Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.CURSE_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Confuse Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.CONFUSE_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Stun Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.STUN_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Perification Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.PERIFICATION_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Stumble Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.STUMBLE_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Stagger Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.STAGGER_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("OpenAreial Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.OPENAREIAL_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Snare Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SNARE_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Slow Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SLOW_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("Spin Arp")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.SPIN_RESISTANCE_PENETRATION, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("MagicalSkillBoost")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.BOOST_MAGICAL_SKILL, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("MagicalHitAccuracy")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAGICAL_ACCURACY, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("BoostCastingTime")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.BOOST_CASTING_TIME, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("HealSkillBoost")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.HEAL_BOOST, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("PhysicalCriticalReduceRate")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.PHYSICAL_CRITICAL_RESIST, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("MagicalCriticalReduceRate")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAGICAL_CRITICAL_RESIST, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("PhysicalCriticalDamageReduce")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.PHYSICAL_CRITICAL_DAMAGE_REDUCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("MagicalCriticalDamageReduce")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAGICAL_CRITICAL_DAMAGE_REDUCE, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("magicalDefend")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAGICAL_DEFEND, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    else if (action.equalsIgnoreCase("MagicalSkillBoostResist")) {
                        if (value < 99999999) {
                            List functions = new ArrayList();
                            functions.add(new StatChangeFunction(StatEnum.MAGIC_SKILL_BOOST_RESIST, value));
                            admin.getGameStats().addEffect(this, functions);
                            PacketSendUtility.broadcastPacket(admin, new SM_EMOTION(admin, EmotionType.START_EMOTE2, 0, 0), true);
                        }
                    }
                    }
                }
                break;
            case TELEPORTTO:
                TeleportService2.teleportTo(admin, player.getWorldId(), player.getX(), player.getY(), player.getZ());
                break;
            case RESURRECT:
                PlayerReviveService.skillRevive(admin);
                break;
            case INVISIBLE:
                admin.getEffectController().setAbnormal(AbnormalState.HIDE.getId());
                admin.setVisualState(CreatureVisualState.HIDE20);
                PacketSendUtility.broadcastPacket(admin, new SM_PLAYER_STATE(admin), true);
                PacketSendUtility.sendMessage(admin, "You are invisible.");
                break;
            case VISIBLE:
                admin.getEffectController().unsetAbnormal(AbnormalState.HIDE.getId());
                admin.unsetVisualState(CreatureVisualState.HIDE20);
                PacketSendUtility.broadcastPacket(admin, new SM_PLAYER_STATE(admin), true);
                PacketSendUtility.sendMessage(admin, "You are invisible.");
                break;
            /**
             * @CHARACTER SETTING TAB
             */
            case LEVELDOWN:
                if (target != null) {
                    if (parts.length == 2) {
                        Integer level = Integer.parseInt(parts[1]);
                        if (level > 0 ) {
                            if (target.getCommonData().getLevel() - level >= 1) {
                                int newLevel = target.getCommonData().getLevel() - level;
                                target.getCommonData().setLevel(newLevel);
                            } else {
                                PacketSendUtility.sendMessage(player, "The value of  will plus calculated to the current player level!");
                            }
                        }
                    }
                }
                break;
            case LEVELUP:
                if (target != null) {
                    if (parts.length == 2) {
                        Integer level = Integer.parseInt(parts[1]);
                        if (level > 0 ) {
                            if (target.getCommonData().getLevel() + level <= GSConfig.PLAYER_MAX_LEVEL) {
                                int newLevel = target.getCommonData().getLevel() + level;
                                target.getCommonData().setLevel(newLevel);
                            } else {
                                PacketSendUtility.sendMessage(player, "The value of  will plus calculated to the current player level!");
                            }
                        }
                    }
                }
                break;
            case CHANGECLASS:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case DELETECQUEST:
                if (target != null) {
                    if (parts.length == 2) {
                        Integer questID = Integer.parseInt(parts[1]);
                        if (questID > 0 ) {
                            QuestStateList list = admin.getQuestStateList();
                            if (list == null || list.getQuestState(questID) == null) {
                                PacketSendUtility.sendMessage(admin, "Quest not deleted.");
                            } else {
                                QuestState qs = list.getQuestState(questID);
                                qs.setQuestVar(0);
                                qs.setCompleteCount(0);
                                qs.setStatus(null);
                                if (qs.getPersistentState() != PersistentState.NEW)
                                    qs.setPersistentState(PersistentState.DELETED);
                                PacketSendUtility.sendPacket(admin, new SM_QUEST_COMPLETED_LIST(admin.getQuestStateList().getAllFinishedQuests()));                admin.getController().updateNearbyQuests();
                            }
                        }
                    }
                }
                break;
            case ADDQUEST:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case ENDQUEST:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case SETINVENTORYGROWTH:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case SKILLPOINT:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case COMBINESKILL:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case ADDSKILL:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case DELETESKILL:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case GIVETITLE:
                if (parts.length == 2) {
                    Integer titleId = Integer.parseInt(parts[1]);
                    if ((titleId > 272) || (titleId < 1)) {
                        PacketSendUtility.sendMessage(admin, "title id " + titleId + " is invalid (must be between 1 and 272)");
                    } else {
                        if (target != null) {
                            if (!target.getTitleList().addTitle(titleId, false, 0)) {
                                PacketSendUtility.sendMessage(player, "you can't add title #" + titleId + " to "
                                        + (target.equals(player) ? "yourself" : target.getName()));
                            } else {
                                PacketSendUtility.sendMessage(player, "you added to " + target.getName() + " title #" + titleId);
                                PacketSendUtility.sendMessage(target, player.getName() + " gave you title #" + titleId);
                            }
                        }
                    }
                }
                break;
            /**
             * @OVERALL FUNCTION TAB
             */
            case ENCHANT100:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case FREEFLY:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            /**
             * @NPC/QUEST/ITEM TAB
             */
            case TELEPORT_TO_NAMED:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case WISH:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            case WISHID:
                //Player target = getTarget(admin);
                if (target != null) {
                    if (parts.length == 3) {
                        Integer qty = Integer.parseInt(parts[1]);
                        Integer itemId = Integer.parseInt(parts[2]);
                        if (qty > 0 && itemId > 0) {
                            if (DataManager.ITEM_DATA.getItemTemplate(itemId) == null) {
                                PacketSendUtility.sendMessage(player, "Item id is incorrect: " + itemId);
                            } else {
                                long count = ItemService.addItem(target, itemId, qty);
                                if (count == 0) {
                                    PacketSendUtility.sendMessage(player, "You successfully gave " + qty + " x [item:" + itemId + "] to " + target.getName() + ".");
                                } else {
                                    PacketSendUtility.sendMessage(player, "Item couldn't be added");
                                }
                            }
                        }
                    }
                }
                break;
            case DELETE_ITEMS:
                PacketSendUtility.sendMessage(admin, "Admin Command Not Implemented: " + command.name());
                break;
            default:
                PacketSendUtility.sendMessage(admin, "Invalid command: " + command.name());
                break;
        }
    }

    private Player getTarget(Player admin) {
        VisibleObject target = admin.getTarget();
        if (target instanceof Player) {
            return (Player) target;
        }
        PacketSendUtility.sendMessage(admin, "Target not found or target is not an player");
        return null;
    }
    class StatChangeFunction extends StatFunction {
        static final int speed = 6000;
        static final int flyspeed = 9000;
        static final int maxDp = 4000;
        int modifier = 1;

        StatChangeFunction(StatEnum stat, int modifier) {
            this.stat = stat;
            this.modifier = modifier;
        }

        @Override
        public void apply(Stat2 stat) {
            switch (this.stat) {
                case SPEED:
                    stat.setBase(speed + (speed * modifier) / 100);
                    break;
                case FLY_SPEED:
                    stat.setBase(flyspeed + (flyspeed * modifier) / 100);
                    break;
                case POWER :
                    short modifierPower = (short) modifier;
                    stat.setBase(Math.round(modifierPower));
                    break;
                case MAXHP:
                    float modifierHp = (float) modifier;
                    stat.setBase(Math.round(modifierHp));
                    break;
                case MAXMP:
                    float modifierMp = (float) modifier;
                    stat.setBase(Math.round(modifierMp));
                    break;
                case REGEN_HP:
                    int baseHp = stat.getOwner().getLevel() + 3;
                    stat.setBase(baseHp *= modifier / 100f);
                    break;
                case REGEN_MP:
                    int baseMp = stat.getOwner().getLevel() + 8;
                    stat.setBase(baseMp *= modifier / 100f);
                    break;
                case MAXDP:
                    stat.setBase(maxDp + (maxDp * modifier) / 100);
                    break;
                case ALLRESIST:
                    short modifierALLR = (short) modifier;
                    stat.setBase(Math.round(modifierALLR));
                    break;
                case ABNORMAL_RESISTANCE_ALL:
                    short modifierAbnormalALLR = (short) modifier;
                    stat.setBase(Math.round(modifierAbnormalALLR));
                    break;
                case STRVIT:
                    short modifierStrvit = (short) modifier;
                    stat.setBase(Math.round(modifierStrvit));
                    break;
                case KNOWIL:
                    short modifierKnowil = (short) modifier;
                    stat.setBase(Math.round(modifierKnowil));
                    break;
                case AGIDEX:
                    short modifierAgidex = (short) modifier;
                    stat.setBase(Math.round(modifierAgidex));
                    break;
                case HEALTH:
                    short modifierHealth = (short) modifier;
                    stat.setBase(Math.round(modifierHealth));
                    break;
                case ACCURACY:
                    short modifierAccuracy = (short) modifier;
                    stat.setBase(Math.round(modifierAccuracy));
                    break;
                case AGILITY:
                    short modifierAgility = (short) modifier;
                    stat.setBase(Math.round(modifierAgility));
                    break;
                case KNOWLEDGE:
                    short modifierKnow = (short) modifier;
                    stat.setBase(Math.round(modifierKnow));
                    break;
                case WILL:
                    short modifierWill = (short) modifier;
                    stat.setBase(Math.round(modifierWill));
                    break;
                case WATER_RESISTANCE:
                    short modifierWaterRes = (short) modifier;
                    stat.setBase(Math.round(modifierWaterRes));
                    break;
                case WIND_RESISTANCE:
                    short modifierWindRes = (short) modifier;
                    stat.setBase(Math.round(modifierWindRes));
                    break;
                case EARTH_RESISTANCE:
                    short modifierEarthRes = (short) modifier;
                    stat.setBase(Math.round(modifierEarthRes));
                    break;
                case FIRE_RESISTANCE:
                    short modifierFireRes = (short) modifier;
                    stat.setBase(Math.round(modifierFireRes));
                    break;
                case REGEN_FP:
                    stat.setBase(Math.round(modifier));
                    break;
                case PHYSICAL_DEFENSE:
                    stat.setBase(Math.round(modifier));
                    break;
                case MAGICAL_ATTACK:
                    short modifierMAttack = (short) modifier;
                    stat.setBase(Math.round(modifierMAttack));
                    break;
                case MAGICAL_RESIST:
                    short modifierMResist = (short) modifier;
                    stat.setBase(Math.round(modifierMResist));
                    break;
                case ATTACK_SPEED:
                    short modifierASpeed = (short) modifier;
                    stat.setBase(Math.round(modifierASpeed / 2));
                    break;
                case EVASION:
                    short modifierEvasion = (short) modifier;
                    stat.setBase(Math.round(modifierEvasion));
                    break;
                case PARRY:
                    short modifierParry = (short) modifier;
                    stat.setBase(Math.round(modifierParry));
                    break;
                case BLOCK:
                    short modifierBlock = (short) modifier;
                    stat.setBase(Math.round(modifierBlock));
                    break;
                case PHYSICAL_CRITICAL:
                    short modifierPCrit = (short) modifier;
                    stat.setBase(Math.round(modifierPCrit));
                    break;
                case HIT_COUNT:
                    short modifierHCount = (short) modifier;
                    stat.setBase(Math.round(modifierHCount));
                    break;
                case ATTACK_RANGE:
                    float modifierARange = (float) modifier;
                    stat.setBase(Math.round(modifierARange));
                    break;
                case MAGICAL_CRITICAL:
                    short modifierMCrit = (short) modifier;
                    stat.setBase(Math.round(modifierMCrit));
                    break;
                case CONCENTRATION:
                    short modifierConcentration = (short) modifier;
                    stat.setBase(Math.round(modifierConcentration));
                    break;
                case POISON_RESISTANCE:
                    short modifierPResist = (short) modifier;
                    stat.setBase(Math.round(modifierPResist));
                    break;
                case BLEED_RESISTANCE:
                    short modifierBResist = (short) modifier;
                    stat.setBase(Math.round(modifierBResist));
                    break;
                case PARALYZE_RESISTANCE:
                    short modifierPAResist = (short) modifier;
                    stat.setBase(Math.round(modifierPAResist));
                    break;
                case SLEEP_RESISTANCE:
                    short modifierSResist = (short) modifier;
                    stat.setBase(Math.round(modifierSResist));
                    break;
                case ROOT_RESISTANCE:
                    short modifierRResist = (short) modifier;
                    stat.setBase(Math.round(modifierRResist));
                    break;
                case BLIND_RESISTANCE:
                    short modifierBLResist = (short) modifier;
                    stat.setBase(Math.round(modifierBLResist));
                    break;
                case CHARM_RESISTANCE:
                    short modifierCResist = (short) modifier;
                    stat.setBase(Math.round(modifierCResist));
                    break;
                case DISEASE_RESISTANCE:
                    short modifierDResist = (short) modifier;
                    stat.setBase(Math.round(modifierDResist));
                    break;
                case SILENCE_RESISTANCE:
                    short modifierSIResist = (short) modifier;
                    stat.setBase(Math.round(modifierSIResist));
                    break;
                case FEAR_RESISTANCE:
                    short modifierFResist = (short) modifier;
                    stat.setBase(Math.round(modifierFResist));
                    break;
                case CURSE_RESISTANCE:
                    short modifierCUResist = (short) modifier;
                    stat.setBase(Math.round(modifierCUResist));
                    break;
                case CONFUSE_RESISTANCE:
                    short modifierCOResist = (short) modifier;
                    stat.setBase(Math.round(modifierCOResist));
                    break;
                case STUN_RESISTANCE:
                    short modifierSTResist = (short) modifier;
                    stat.setBase(Math.round(modifierSTResist));
                    break;
                case PERIFICATION_RESISTANCE:
                    short modifierPEResist = (short) modifier;
                    stat.setBase(Math.round(modifierPEResist));
                    break;
                case STUMBLE_RESISTANCE:
                    short modifierSTUResist = (short) modifier;
                    stat.setBase(Math.round(modifierSTUResist));
                    break;
                case STAGGER_RESISTANCE:
                    short modifierSTAResist = (short) modifier;
                    stat.setBase(Math.round(modifierSTAResist));
                    break;
                case OPENAREIAL_RESISTANCE:
                    short modifierOResist = (short) modifier;
                    stat.setBase(Math.round(modifierOResist));
                    break;
                case SNARE_RESISTANCE:
                    short modifierSNResist = (short) modifier;
                    stat.setBase(Math.round(modifierSNResist));
                    break;
                case SLOW_RESISTANCE:
                    short modifierSLResist = (short) modifier;
                    stat.setBase(Math.round(modifierSLResist));
                    break;
                case SPIN_RESISTANCE:
                    short modifierSPResist = (short) modifier;
                    stat.setBase(Math.round(modifierSPResist));
                    break;
                case POISON_RESISTANCE_PENETRATION:
                    short modifierPRP = (short) modifier;
                    stat.setBase(Math.round(modifierPRP));
                    break;
                case BLEED_RESISTANCE_PENETRATION:
                    short modifierBRP = (short) modifier;
                    stat.setBase(Math.round(modifierBRP));
                    break;
                case PARALYZE_RESISTANCE_PENETRATION:
                    short modifierPARP = (short) modifier;
                    stat.setBase(Math.round(modifierPARP));
                    break;
                case SLEEP_RESISTANCE_PENETRATION:
                    short modifierSRP = (short) modifier;
                    stat.setBase(Math.round(modifierSRP));
                    break;
                case ROOT_RESISTANCE_PENETRATION:
                    short modifierRRP = (short) modifier;
                    stat.setBase(Math.round(modifierRRP));
                    break;
                case BLIND_RESISTANCE_PENETRATION:
                    short modifierBLRP = (short) modifier;
                    stat.setBase(Math.round(modifierBLRP));
                    break;
                case CHARM_RESISTANCE_PENETRATION:
                    short modifierCRP = (short) modifier;
                    stat.setBase(Math.round(modifierCRP));
                    break;
                case DISEASE_RESISTANCE_PENETRATION:
                    short modifierDRP = (short) modifier;
                    stat.setBase(Math.round(modifierDRP));
                    break;
                case SILENCE_RESISTANCE_PENETRATION:
                    short modifierSIRP = (short) modifier;
                    stat.setBase(Math.round(modifierSIRP));
                    break;
                case FEAR_RESISTANCE_PENETRATION:
                    short modifierFRP = (short) modifier;
                    stat.setBase(Math.round(modifierFRP));
                    break;
                case CURSE_RESISTANCE_PENETRATION:
                    short modifierCURP = (short) modifier;
                    stat.setBase(Math.round(modifierCURP));
                    break;
                case CONFUSE_RESISTANCE_PENETRATION:
                    short modifierCORP = (short) modifier;
                    stat.setBase(Math.round(modifierCORP));
                    break;
                case STUN_RESISTANCE_PENETRATION:
                    short modifierSTRP = (short) modifier;
                    stat.setBase(Math.round(modifierSTRP));
                    break;
                case PERIFICATION_RESISTANCE_PENETRATION:
                    short modifierPERP = (short) modifier;
                    stat.setBase(Math.round(modifierPERP));
                    break;
                case STUMBLE_RESISTANCE_PENETRATION:
                    short modifierSTURP = (short) modifier;
                    stat.setBase(Math.round(modifierSTURP));
                    break;
                case STAGGER_RESISTANCE_PENETRATION:
                    short modifierSTARP = (short) modifier;
                    stat.setBase(Math.round(modifierSTARP));
                    break;
                case OPENAREIAL_RESISTANCE_PENETRATION:
                    short modifierORP = (short) modifier;
                    stat.setBase(Math.round(modifierORP));
                    break;
                case SNARE_RESISTANCE_PENETRATION:
                    short modifierSNRP = (short) modifier;
                    stat.setBase(Math.round(modifierSNRP));
                    break;
                case SLOW_RESISTANCE_PENETRATION:
                    short modifierSLRP = (short) modifier;
                    stat.setBase(Math.round(modifierSLRP));
                    break;
                case SPIN_RESISTANCE_PENETRATION:
                    short modifierSPRP = (short) modifier;
                    stat.setBase(Math.round(modifierSPRP));
                    break;
                case BOOST_MAGICAL_SKILL:
                    short modifierBMSkill = (short) modifier;
                    stat.setBase(Math.round(modifierBMSkill));
                    break;
                case MAGICAL_ACCURACY:
                    short modifierMAccuracy = (short) modifier;
                    stat.setBase(Math.round(modifierMAccuracy));
                    break;
                case BOOST_CASTING_TIME:
                    short modifierBCTime = (short) modifier;
                    stat.setBase(Math.round(modifierBCTime));
                    break;
                case HEAL_BOOST:
                    short modifierHBoost = (short) modifier;
                    stat.setBase(Math.round(modifierHBoost));
                    break;
                case PHYSICAL_CRITICAL_RESIST:
                    short modifierPCResist = (short) modifier;
                    stat.setBase(Math.round(modifierPCResist));
                    break;
                case MAGICAL_CRITICAL_RESIST:
                    short modifierMCResist = (short) modifier;
                    stat.setBase(Math.round(modifierMCResist));
                    break;
                case PHYSICAL_CRITICAL_DAMAGE_REDUCE:
                    short modifierPCDReduce = (short) modifier;
                    stat.setBase(Math.round(modifierPCDReduce));
                    break;
                case MAGICAL_CRITICAL_DAMAGE_REDUCE:
                    short modifierMCDReduce = (short) modifier;
                    stat.setBase(Math.round(modifierMCDReduce));
                    break;
                case MAGICAL_DEFEND:
                    stat.setBase(Math.round(modifier));
                    break;
                case MAGIC_SKILL_BOOST_RESIST:
                    short modifierMSBResist = (short) modifier;
                    stat.setBase(Math.round(modifierMSBResist));
                    break;
                default:
                    break;
            }
        }

        @Override
        public int getPriority() {
            return 60;
        }
    }

}
